package com.fjp.heartguard.viewmodel

import androidx.lifecycle.MutableLiveData
import com.fjp.heartguard.app.base.HTBaseViewModel
import com.fjp.heartguard.app.network.HttpRequestCoroutine
import com.fjp.heartguard.ui.question.QuestionActivity
import me.hgj.jetpackmvvm.ext.requestNoCheck
import okhttp3.MultipartBody

class AutographViewModel : HTBaseViewModel() {
    var updateImageFailed = MutableLiveData<Boolean>()
    var updateImageSuccess = MutableLiveData<Boolean>()

    fun updateSingle(body: MultipartBody.Part) {
        requestNoCheck({ HttpRequestCoroutine.uploadImg(body) }, {
            //请求成功 自己拿到数据做业务需求操作
            if (it.status == "success") {
                QuestionActivity.olderInfo.signature = it.data
                updateImageSuccess.postValue(true)
            }
        }, {
            updateImageFailed.value = true
        }, true,"正在保存签名...")
    }
}